# Contributor: Duncan Bellamy <dunk@denkimushi.com>
# Maintainer: Duncan Bellamy <dunk@denkimushi.com>
pkgname=xnvme
pkgver=0.7.5
pkgrel=0
pkgdesc="cross-platform libraries and tools for NVMe devices"
url="https://xnvme.io"
# 32bit unsupported
arch="all !armhf !armv7 !x86"
license="BSD-3-Clause"
makedepends="bsd-compat-headers libaio-dev liburing-dev linux-headers meson py3-gpep517 py3-setuptools py3-wheel"
subpackages="py3-$pkgname-pyc py3-$pkgname:_python:noarch $pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver-1.tar.gz::https://github.com/xnvme/xnvme/archive/refs/tags/v$pkgver.tar.gz
	basename.patch
	"
case "$CARCH" in
aarch64|x86_64) makedepends="$makedepends libvfn-dev" ;;
esac

build() {
	abuild-meson -Dexamples=false -Dwith-spdk=disabled \
		. output
	meson compile -C output

	cd python/bindings
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	meson test --no-rebuild --print-errorlogs -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output

	cd python/bindings
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
	rm -r "$pkgdir"/usr/lib/python3*/site-packages/xnvme/ctypes_bindings/tests
}

_python() {
	amove usr/lib/python*
}

sha512sums="
c82e1d8f5460e29270afd650c6726e2b1156f382d379e360c81246e1c651dad0b4ae814e0a3db495f83186269fe7c23ae0ea4488a39d10019a11e0a17ba0b014  xnvme-0.7.5-1.tar.gz
c9bae17b305efc246fec3e3d9e02a9c3657cf210b1b5ece2af40fb0c69428be720e0e2f94c857860691922175c4e77de964a1c91b7468dd44ed5413f85f14e0f  basename.patch
"
